package com.xs;


import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.xs.business.user.service.UserServiceImpl;



/**
 * @Title: <P>AppStart.java</P>
 * @Package <P>com.xs</P>
 * @Description: <P>主类运行</P>
 * @author renweiping
 * @date 2019年1月15日 下午4:02:41
 * @version 1.0
 */

public class AppStart {

	/**
	 * @Description: 主类运行
	 * @param @param args   
	 * @return void  
	 * @throws LifecycleException 
	 * @throws
	 * @author renweiping
	  *@e_mail renweiping_1113@google.com
	 * @date 2019年1月15日
	 */

	public static void main(String[] args) /*throws LifecycleException*/ {

/*		String webappDirLocation = System.getProperty("user.dir")+File.separator +"src"+File.separator+"main"+File.separator+"webapp";
		Tomcat tomcat = new Tomcat();


		String webPort = System.getenv("PORT");
		if(webPort == null || webPort.isEmpty()) {
			webPort = "8080";
		}

		tomcat.setPort(Integer.valueOf(webPort));

		StandardContext ctx = (StandardContext) tomcat.addWebapp("/", new File(webappDirLocation).getAbsolutePath());
		System.out.println("configuring app with basedir: " + new File("./" + webappDirLocation).getAbsolutePath());

		File additionWebInfClasses = new File("target/classes");
		WebResourceRoot resources = new StandardRoot(ctx);
		resources.addPreResources(new DirResourceSet(resources, "/WEB-INF/classes",
				additionWebInfClasses.getAbsolutePath(), "/"));
		ctx.setResources(resources);

		tomcat.start();
		tomcat.getServer().await();*/

	}
	
	
	//打包时
	public static void main2(String[] args) /*throws LifecycleException*/ {

	/*	String webappDirLocation = "webapp";
		System.out.println("webappDirLocation=" + new File(webappDirLocation).getAbsolutePath());
		Tomcat tomcat = new Tomcat();
		tomcat.setPort(9090);*/

		// 设置webapp路径 
/*		StandardContext ctx = (StandardContext) tomcat.addWebapp("", new File(webappDirLocation).getAbsolutePath());
		ctx.setReloadable(false);*/
		// 设置资源地址
/*		File additionWebInfClasses = new File("webapp/WEB-INF/classes");
		WebResourceRoot resources = new StandardRoot(ctx);
		resources.addPreResources(
				new DirResourceSet(resources, "/WEB-INF/classes", additionWebInfClasses.getAbsolutePath(), "/"));
*/
		// 设置web xml
/*		ctx.setDefaultWebXml("webapp/WEB-INF/web.xml");

		tomcat.start();
		tomcat.getServer().await();*/

	}
	
	public static void main33(String[] args) {
		//ThreadPoolTaskExecutor 
		ApplicationContext ac = new ClassPathXmlApplicationContext("spring-context.xml");
		
		UserServiceImpl u = (UserServiceImpl) ac.getBean("userServiceImpl");
		/*ac.getBean(name)*/
		System.out.println(u);
	}
	
	

}
